Storing static array in skip list

Hello

is it possible to store a static array inside a skip?

I tried something like following but it is not working.

 

Skip sl = createString()

put(sl, "modPth", {"ID_1", "ID_2"})

 

Any ideas?

Br

Chris


leporello - Wed Nov 08 09:46:57 EST 2017

Re: Storing static array in skip list
pommCannelle - Fri Nov 10 05:44:37 EST 2017

( have You tried to use a variable ?

 

Skip skp = createString
string test[] = {"ID 1", "ID 2"} 
put( skp, "first", test)

string retrieved[]
if ( find(skp, "first", retrieved) ) {
   print retrieved[0] "\n"
   print retrieved[1] "\n"
} else print "fail\n"

delete skp

   ;)

)

Re: Storing static array in skip list
Mathias Mamsch - Mon Nov 13 03:00:10 EST 2017

pommCannelle - Fri Nov 10 05:44:37 EST 2017

( have You tried to use a variable ?

 

Skip skp = createString
string test[] = {"ID 1", "ID 2"} 
put( skp, "first", test)

string retrieved[]
if ( find(skp, "first", retrieved) ) {
   print retrieved[0] "\n"
   print retrieved[1] "\n"
} else print "fail\n"

delete skp

   ;)

)

Careful. Putting a simple array inside a skip list invites for crashes, since simple arrays are only valid inside the function where they are declared. If you create a simple array inside a function a pass it as a return value to the outside, the memory will be freed and you will get crashes. Use an "Array" or a nested "Skip" instead. Regards, Mathias

Re: Storing static array in skip list
leporello - Tue Nov 14 05:59:09 EST 2017

pommCannelle - Fri Nov 10 05:44:37 EST 2017

( have You tried to use a variable ?

 

Skip skp = createString
string test[] = {"ID 1", "ID 2"} 
put( skp, "first", test)

string retrieved[]
if ( find(skp, "first", retrieved) ) {
   print retrieved[0] "\n"
   print retrieved[1] "\n"
} else print "fail\n"

delete skp

   ;)

)

Hi

yes I've tried that and that would fly.

But I had an excel sheet with lots of modulepathes and corresponding Ids and this solution means to create a variable for each skip.

That was too much effort. I just wanted to concatenate some cell content to have the dxl code for filling up a skip which I can copy/paste into my code quickly.

Also the nested Skip solution was on my mind, but this task was only a fire-and-forget task.

So in the end I packed the IDs into a semicolon separated string, concatenated with my remaining info in excel to fill my skip.

Later I parsed the IDs out of the string.

 

Thanks & regards

Chris